package com.atguigu.cloud.controller;

import com.atguigu.cloud.config.TestConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("nacosTest")
@RestController
public class NacosTestController {

    @Value(value = "${common}")
    private String common;

    @Value(value = "${nacos-test}")
    private String nacosTest;

    @Value(value = "${nacos-test-extension}")
    private String nacosTestExtension;

    @Autowired
    private TestConfig testConfig;

    @RequestMapping("getUsername")
    public String getUsername() {
        System.out.println("username = " + common);
        System.out.println("nacosTest = " + nacosTest);
        System.out.println("nacosTestExtension = " + nacosTestExtension);
        return common + " " + nacosTest + " " + nacosTestExtension;
    }

    @RequestMapping("getTestConfig")
    public String getTestConfig() {
        return testConfig.toString();
    }

}
